package com.lhkj.ct.meta.modules.auth.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.lhkj.ct.base.json.databind.BaseEnumWritingByLabelSerializer;
import com.lhkj.ct.meta.modules.auth.common.enums.IdentType;
import com.lhkj.ct.meta.modules.auth.common.enums.UserType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 第三方授权表
 * </p>
 *
 * @author jobob
 * @since 2023-11-13
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="TblUserIdentity对象", description="第三方授权表")
public class TblUserIdentity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "关联id")
    private String id;

    @NotBlank(message = "用户id不能为空")
    @ApiModelProperty(value = "用户id")
    private String userId;

    @NotNull(message = "用户类型不能为空")
    @ApiModelProperty(value = "用户类型 1.后台 2.平台用户")
    private UserType userType;

    @ApiModelProperty(value = "第三方昵称")
    private String nickName;

    @NotBlank(message = "第三方唯一标识不能为空")
    @ApiModelProperty(value = "第三方唯一标识")
    private String identifier;

    @NotNull(message = "第三方应用类型不能为null")
    @ApiModelProperty(value = "第三方应用类型 1.账号 2.公众号等")
    @JsonSerialize(using = BaseEnumWritingByLabelSerializer.class)
    private IdentType identType;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.UPDATE)
    @ApiModelProperty(value = "修改时间")
    private LocalDateTime updateTime;

    public static TblUserIdentity.TblUserIdentityBuilder builder() {
        return new TblUserIdentity.TblUserIdentityBuilder();
    }

    public static class TblUserIdentityBuilder {
        private final TblUserIdentity userIdentity;

        public TblUserIdentityBuilder() {
            userIdentity = new TblUserIdentity();
        }

        public TblUserIdentity.TblUserIdentityBuilder id(String id) {
            this.userIdentity.id = id;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder userId(String userId) {
            this.userIdentity.userId = userId;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder userType(UserType userType) {
            this.userIdentity.userType = userType;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder nickName(String nickName) {
            this.userIdentity.nickName = nickName;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder identifier(String identifier) {
            this.userIdentity.identifier = identifier;
            return this;
        }


        public TblUserIdentity.TblUserIdentityBuilder identType(IdentType identType) {
            this.userIdentity.identType = identType;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder createTime(LocalDateTime createTime) {
            this.userIdentity.createTime = createTime;
            return this;
        }

        public TblUserIdentity.TblUserIdentityBuilder updateTime(LocalDateTime updateTime) {
            this.userIdentity.updateTime = updateTime;
            return this;
        }
        public TblUserIdentity build() {
            return this.userIdentity;
        }
    }

}
